﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HNCDataSetTableAdapters;

public partial class UserControl_footer : System.Web.UI.UserControl
{
    InfoTableAdapter info = new InfoTableAdapter();
    ProductsTableAdapter pro = new ProductsTableAdapter();
    CategoryTableAdapter cate = new CategoryTableAdapter();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            yahoo();
            yahoo1();
            //skype();
            //counter();
            ltrProduct.Text = loadProduct();
            ltrService.Text = loadService();
            ltrTop4News.Text = loadNews();
            loadfooter();
        }
    }


    public string loadProduct()
    {
        //DataTable dt = pro.GetProductByCateIDTop(4, 3);
        DataTable dt = cate.GetCateByParentID(3);
        string str = "";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string CateID = dt.Rows[i]["CateID"].ToString();
            string Title = dt.Rows[i]["Title"].ToString();
            str += " <li><a href=\"san-pham-" + CateID + ".html\">" + Title + "</a></li>";
        }
        return str;
    }



    public string loadService()
    {
        DataTable dt = cate.GetCateByParentID(7);
        string str = "";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string CateID = dt.Rows[i]["CateID"].ToString();
            string Title = dt.Rows[i]["Title"].ToString();
            str += " <li><a href=\"san-pham-" + CateID + ".html\">" + Title + "</a></li>";
        }
        return str;
    }

    public string loadNews()
    {
        DataTable dt = pro.GetProductByCateIDTop(3, 4);
        string str = "";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string ProductID = dt.Rows[i]["ProductID"].ToString();
            string Title = dt.Rows[i]["Title"].ToString();
            str += " <li><a href=\"chi-tiet-tin-tuc-du-an-" + ProductID + ".html\">" + Title + "</a></li>";
        }
        return str;
    }

    public void loadfooter()
    {
        DataTable dt = info.GetInfoByID(1);

        imgLogo.ImageUrl = "~/UserUploads/Banner/" + dt.Rows[0]["Image"].ToString();
        imgLogo.ToolTip = dt.Rows[0]["Title"].ToString();
        lblTitle.Text = dt.Rows[0]["Title"].ToString();
        lblAddress.Text = dt.Rows[0]["Address"].ToString();
        lblPhone.Text = dt.Rows[0]["Phone"].ToString();
        lblMail.Text = dt.Rows[0]["Email"].ToString();
    }

    public void yahoo()
    {
        DataTable dt = info.GetInfoByID(1);
        string yahoo = dt.Rows[0]["Yahoo"].ToString();
        string title = dt.Rows[0]["GooglePlus1"].ToString();
        string tem = "";

        tem += @"
                <a class='yahoo' href='ymsgr:sendim?" + yahoo + @"'>
                                <img style='border: none;height:18px;width:18px' src='http://opi.yahoo.com/online?u=" + yahoo + @"&amp;m=g&amp;t=0'>
                            </a>&nbsp; &nbsp;" + title + @"";


        ltryahoo.Text = tem;
    }

    public void yahoo1()
    {
        DataTable dt = info.GetInfoByID(1);
        string yahoo1 = dt.Rows[0]["Yahoo1"].ToString();
        string title1 = dt.Rows[0]["GooglePlus2"].ToString();
        string tem = "";

        tem += @"
                <a class='yahoo' href='ymsgr:sendim?" + yahoo1 + @"'>
                                <img style='border: none;height:18px;width:18px' src='http://opi.yahoo.com/online?u=" + yahoo1 + @"&amp;m=g&amp;t=0'>
                            </a>&nbsp; &nbsp;" + title1 + @"";

        ltryahoo1.Text = tem;
    }

    //    public void skype()
    //    {
    //        DataTable dt = info.GetInfoByID(1);
    //        string Skype = dt.Rows[0]["Skype"].ToString();
    //        string tem = "";

    //            tem += @"
    //                    <a href='skype:" + Skype + @"?chat'><img style='border: none;height:20px;width:70px' src='http://mystatus.skype.com/balloon/" + Skype + @"' alt='" + "" + @"' /></a><br />
    //                ";        
    //        ltrskype.Text = tem;
    //    }

    //    public void counter()
    //    {
    //        lbOnlne.Text = Application.Get("Online").ToString();
    //        lbLuottruycap.Text = Application.Get("Access").ToString();
    //    }
}